﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TeamsPortal.DataAccess;

namespace TeamsPortal.ServiceClient
{
    public interface ITopicsServiceClient
    {
        /// <summary>
        /// Gets a list of topics of a forum ordered by views
        /// </summary>
        List<Topic> GetByForum(int forumId, int startIndex, int length, UserRole? role);

        /// <summary>
        /// Gets the topics tagged in a certain forum
        /// </summary>
        /// <returns></returns>
        List<Topic> GetByTag(string tag, int forumId, UserRole? role);

        /// <summary>
        /// Gets a topic by id
        /// </summary>
        /// <param name="topicId"></param>
        /// <returns></returns>
        Topic Get(int topicId);

        /// <summary>
        /// Gets a topic by id, validating that the shortName matches
        /// </summary>
        Topic Get(int id, string shortName);

        void LoadRelatedTopics(Topic topic, int amount);

        /// <exception cref="ValidationException"></exception>
        void Create(Topic topic, string ip);

        /// <summary>
        /// Edits a topic
        /// </summary>
        /// <exception cref="ValidationException"></exception>
        void Edit(Topic topic, string ip);

        void AddVisit(int topicId);

        List<Topic> GetLatest(int forumId, int startIndex, int length, UserRole? role, int? userId = null);

        List<Topic> GetLatest();

        /// <summary>
        /// Moves a topic from a forum to another.
        /// </summary>
        Topic Move(int id, int forumId, int userId, string ip);

        /// <summary>
        /// Closes a topic to disallow further replies.
        /// </summary>
        void Close(int id, int userId, string ip);

        /// <summary>
        /// Opens a topic to allow replies.
        /// </summary>
        void Open(int id, int userId, string ip);

        /// <summary>
        /// Gets a list of unanswered topics
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        List<Topic> GetUnanswered(int forumId, UserRole? role);

        /// <summary>
        /// Gets a list of unanswered topics from all forums
        /// </summary>
        /// <returns></returns>
        List<Topic> GetUnanswered();

        /// <summary>
        /// Deletes (inactive) a user from the application
        /// </summary>
        void Delete(int id, int userId, string ip);

        /// <summary>
        /// Gets a list of topics posted by the user
        /// </summary>
        /// <param name="role">Role of the user requesting the page</param>
        List<Topic> GetByUser(int userId, UserRole? role);

        /// <summary>
        /// Gets a list of topics with the messages posted by the user
        /// </summary>
        List<Topic> GetTopicsAndMessagesByUser(int userId);

        /// <summary>
        /// Get a topic containing an specific amount of messages starting from firstMsg
        /// </summary>
        Topic GetMessagesFrom(int topicId, int firstMsg, int amount);

        /// <summary>
        /// Gets a topic containing messages from firstMsg to lastMsg
        /// </summary>
        Topic GetMessages(int topicId, int firstMsg, int lastMsg);
    }
}
